﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zor_Modes;
using Zor_IDAL;
using Zor_Tools;
using System.Data;
using Dapper;

namespace Zor_DAL
{
    public class AnnualTaskMap_DAL<T> where T : class
    {
       
        
        /// <summary>
        /// 获取GIS年度税收地图数据
        /// </summary>
        /// <returns></returns>
        public static List<T> GetAnnualTaskInfo()
        {
            var now = DateTime.Now;
            var nowYear = now.Year;
            var nowStatDate = nowYear + "-" + 01 + "-" + 01; //获取当前的1月1日
            var nowMonth = now.Month;
            var nowEndDate = nowYear + "-" + nowMonth + "-" + 01;  //获取当前月的1日
            var  strWhere = "Pt_Date >=" + TimeHelper.ToTimeStamp(DateTime.Parse(nowStatDate)) + " and Pt_Date<=" + TimeHelper.ToTimeStamp(DateTime.Parse(nowEndDate)) + "";

            var sql = "select  Dt_Id,Dt_Name,Dt_BD_Latitude,Dt_BD_Longitude,SUM(ANumber) as ANumber,shopNumber,houNumber,SUM(xiaoji) as xiaoji from [V_AnnualTaskMap] where  " + strWhere + " group by Dt_Id,Dt_Name,Dt_BD_Latitude,Dt_BD_Longitude,shopNumber,houNumber";
            return DapperQuery<T>.DoQueryList(sql, null);
        }

        /// <summary>
        /// 获取GIS社区地图数据
        /// </summary>
        /// <returns></returns>
        public static List<T> GetMap()
        {
            var sql = "select * from [dbo].[Sys_Department] where Dt_Id =  " + RequestSession.GetSessionUser().DT_Id + " ";
            return DapperQuery<T>.DoQueryList(sql, null);
        }
    }
}
